package com.woniu.adopt.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.adopt.entity.Comment;
import com.woniu.adopt.entity.RescueStation;
import com.woniu.adopt.mapper.CommentMapper;
import com.woniu.adopt.vo.CommentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentService {

    @Autowired
    CommentMapper commentMapper;

    //模糊查询 （救助站名称，地址）+ 分页
    public PageInfo<CommentVo> queryCommentByPage(Integer now, Integer size, String uname, String pname) {
        PageHelper.startPage(now, size);

        List<CommentVo> comments = commentMapper.selectAllByDel(uname, pname);

        return new PageInfo<>(comments);
    }


    public CommentVo selectCommentByKey(int id) {
        return commentMapper.selectCommentByKey(id);
    }

    public void updateComment(CommentVo commentVo) {

         commentMapper.updateCommentByKey(commentVo);
    }

    public int removeComment(int id) {
       return commentMapper.updateCommentByDel(id);
    }
}
